#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>

int cmp(const void* a, const void* b)
{
    return *(int*)a - *(int*)b;
}
int* MySort(int* arr, int arrLen, int* returnSize)
{
    *returnSize = arrLen;
    qsort(arr, arrLen, sizeof(arr[0]), cmp);

    return arr;
}

int search(int* nums, int numsLen, int target)
{
    int left = 0;
    int right = numsLen - 1;
    while (left <= right)
    {
        int mid = left + (right - left) / 2;
        // left mid right [ ] 
        if (nums[mid] < target)
        {
            left = mid + 1;
        }
        else if (nums[mid] > target)
        {
            right = mid - 1;
        }
        else
        {
            return mid;
        }
    }
    return -1;
}
